from __future__ import absolute_import
import os
from celery import Celery

# 设置默认的 Django 设置模块
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')

app = Celery('myproject')

# 从 settings.py 中加载配置
app.config_from_object('django.conf:settings', namespace='CELERY')

# 显式列出我们希望Celery发现任务的应用
app.autodiscover_tasks(['processutil', 'link'])

@app.task(bind=True)
def debug_task(self):
    print(f'Request: {self.request!r}')

# from __future__ import absolute_import
# import os
# from celery import Celery

# os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')

# app = Celery('myproject')
# app.config_from_object('django.conf:settings', namespace='CELERY')
# app.autodiscover_tasks()